package com.sunq.studio.resource.service.impl;

import com.sunq.studio.resource.dao.TbPicResourceDao;
import com.sunq.studio.resource.domain.TbPicResource;
import com.sunq.studio.resource.service.ResourceService;
import com.sunq.studio.sys.dao.SysResourceContentDao;
import com.sunq.studio.sys.domain.SysResourceContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by sunq on 2019/7/10.
 */
@Service
public class ResourceServiceImpl implements ResourceService {

    @Autowired
    private TbPicResourceDao tbPicResourceDao;

    @Autowired
    private SysResourceContentDao sysResourceContentDao;

    @Override
    public TbPicResource addPicResource(String picUrl,Integer resId) {
        TbPicResource res=new TbPicResource();
        res.setPicUrl(picUrl);
        res.setCreateTime(new Date());
        res.setResClassify("class");
        res.setResId(resId);
        res.setResType("pic");
        res.setDelFlag(0);
        tbPicResourceDao.insertSelective(res);
        return res;
    }

    @Override
    public int delPicResource(Integer picId) {

        int i= tbPicResourceDao.deleteByPrimaryKey(picId);
        return i;
    }

    @Override
    public List<SysResourceContent> getResoucesByClassify(int classify) {

        List<SysResourceContent> res=sysResourceContentDao.selectListByClassify(classify);
        return res;
    }
}
